package cn.maihe.elg.operation.supports.electronicseal.kt.cloudsign.service;

import cn.maihe.elg.operation.supports.electronicseal.kt.KtConfig;
import cn.maihe.elg.operation.supports.electronicseal.kt.cloudsign.BaseKtCloudSignService;
import cn.maihe.elg.operation.supports.electronicseal.kt.cloudsign.dto.GetAuthSMSReqDTO;
import cn.maihe.elg.operation.supports.electronicseal.kt.cloudsign.dto.GetAuthSMSRespDTO;
import cn.maihe.elg.operation.supports.electronicseal.kt.cloudsign.enums.CloudSignInterfaceEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description 调用该接口发送用户授权验证码
 * @Author WJH
 * @Date 2022/09/19
 */
@Service@Slf4j
public class GetAuthSMSService extends BaseKtCloudSignService<GetAuthSMSReqDTO, GetAuthSMSRespDTO> {
    public GetAuthSMSService(KtConfig ktConfig) {
        super(ktConfig);
    }

    @Resource
    private ListByMobileService listByMobileService;

    @Override
    protected CloudSignInterfaceEnum serviceName() {
        return CloudSignInterfaceEnum.getAuthSMS;
    }


    public String sendSmsAndGetOpId(String authMobile, List<String> dbUserIds){
        //2.2.1.1.根据手机号获取证章列表 并匹配获取dbUserId的印章
        listByMobileService.existsUserId(authMobile, dbUserIds);

        GetAuthSMSReqDTO reqDTO = new GetAuthSMSReqDTO();
        reqDTO.setMobile(authMobile);
        reqDTO.setUserIdArr(dbUserIds);
        reqDTO.setTime("-1");

        //2.2.1.2.发送短信验证码 获取opid 过期时间设置-1
        GetAuthSMSRespDTO respDTO = this.doService(authMobile, reqDTO);
        String opId = respDTO.getOpId();
        return opId;
    }


}
